package com.ciwong.epaper.modules.scan.ui;


import android.Manifest;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Build;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Toast;

import com.ciwong.epaper.R;
import com.ciwong.epaper.application.EApplication;
import com.ciwong.epaper.bean.HideDownloadDialogBean;
import com.ciwong.epaper.common.guidedialog.ChooseReadDialog;
import com.ciwong.epaper.event.EventBusFactory;
import com.ciwong.epaper.modules.epaper.bean.CatalogueInfo;
import com.ciwong.epaper.modules.epaper.bean.ModuleInfo;
import com.ciwong.epaper.modules.epaper.util.EpaperJumpManager;
import com.ciwong.epaper.modules.epaper.util.HomeWorkUtil;
import com.ciwong.epaper.modules.epaper.util.ListenSpeakUtil;
import com.ciwong.epaper.modules.epaper.util.MultipleServicesDialog;
import com.ciwong.epaper.modules.interactivetutorial.InteractiveTutorialCordovaActivity;
import com.ciwong.epaper.modules.me.bean.CheckValidBean;
import com.ciwong.epaper.modules.me.util.MeJumpManager;
import com.ciwong.epaper.modules.onlineanswer.OnlineAnswerCordovaActivity;
import com.ciwong.epaper.modules.scan.adapter.NewQrDetailAdapter;
import com.ciwong.epaper.modules.viedoexplantion.util.ViedoJumpManager;
import com.ciwong.epaper.util.DialogUtil;
import com.ciwong.epaper.util.ESystem;
import com.ciwong.epaper.util.IntentFlag;
import com.ciwong.epaper.util.RequestCode;
import com.ciwong.epaper.util.ServicePermissionJudgeUtil;
import com.ciwong.epaper.util.download.DownLoad;
import com.ciwong.epaper.util.download.DownLoadDB;
import com.ciwong.epaper.util.download.DownLoadInfo;
import com.ciwong.epaper.util.download.DownloadStatus;
import com.ciwong.eventbus.EventBus;
import com.ciwong.libs.utils.NetworkUtils;
import com.ciwong.libs.widget.CWToast;
import com.ciwong.mobilelib.i.BaseCallBack;
import com.ciwong.mobilelib.utils.ThreadTask;
import com.ciwong.mobilelib.utils.ToastUtil;
import com.ciwong.mobilelib.utils.XXPermissionTool;
import com.ciwong.mobilelib.widget.CWDialog;
import com.ciwong.mobilelib.widget.DownloadProgressBar;
import com.ciwong.mobilelib.widget.TitleBar;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by young on 2017/11/22.
 * 新资源的扫码页面
 */

public class NewTypeQrDetailActivity extends com.ciwong.mobilelib.ui.BaseActivity {

    private ListView list_view;
    private List<DownLoadInfo> downLoadInfos = new ArrayList<DownLoadInfo>();
    private NewQrDetailAdapter newQrDetailAdapter;
    private boolean isPreview;
    private Map<DownLoadInfo, Hoder> downLoadInfoMap = new HashMap<DownLoadInfo, Hoder>();

    private long effectiveDate = -1;

    @Override
    protected int setView() {
        return R.layout.activity_new_content;
    }

    @Override
    protected void findViews() {
        titleBar = (TitleBar) findViewById(R.id.activity_base_titlebar);
        list_view = (ListView) findViewById(R.id.list_view);
    }

    @Override
    protected void initEvent() {
        list_view.setOnItemClickListener(onItemClickListener);
        newQrDetailAdapter = new NewQrDetailAdapter(NewTypeQrDetailActivity.this, downLoadInfos);
        list_view.setAdapter(newQrDetailAdapter);
        setDownloadProgressOnDismissListener(new DownloadProgressBar.OnDownLoadDialogDismissListener() {
            @Override
            public void ondDismiss(DownloadProgressBar downloadProgressBar) {
                if (mCurrentDownloadInfo != null) {
                    int status = mCurrentDownloadInfo.getStatus();
                    if (status == DownloadStatus.STATUS_LOADING || status == DownloadStatus.STATUS_DOWNLOADING) {
                        DownLoad.getInstance().pauseTask(mCurrentDownloadInfo);
                    }
                }
            }
        });
        EventBus.getDefault().register(this);

    }

    @Override
    protected void init() {
        setTitleText("资源详情");
    }

    @Override
    protected void loadData() {
        try {
            downLoadInfos = (ArrayList<DownLoadInfo>) getIntent().getSerializableExtra(IntentFlag.INTENT_FLAG_OBJ);
            isPreview = getIntent().getBooleanExtra(IntentFlag.INTENT_FLAG_PREVIEW, false);
            newQrDetailAdapter.updateData(downLoadInfos);
        } catch (Exception e) {
            e.getStackTrace();
        }

    }

    @Override
    protected void onResume() {
        if (!EventBus.getDownLoadInstance().isRegistered(this)) {
            EventBus.getDownLoadInstance().register(this);
        }
        super.onResume();
    }

    @Override
    protected void onStop() {
        if (EventBus.getDownLoadInstance().isRegistered(this) && !isTopActivity()) {
            EventBus.getDownLoadInstance().unregister(this);
            hideDownloadProgress();
        }
        super.onStop();
    }

    @Override
    protected void onDestroy() {
        if (EventBus.getDownLoadInstance().isRegistered(this)) {
            EventBus.getDownLoadInstance().unregister(this);
        }
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
        super.onDestroy();
    }

    private AdapterView.OnItemClickListener onItemClickListener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View convertView, int position, long id) {
            try {
                DownLoadInfo downLoadInfo = downLoadInfos.get(position);
                Hoder hoder = new Hoder();
                mCurrentClickDownloadInfo = downLoadInfo;
                hoder.imageView_download = (ImageView) convertView.findViewById(R.id.item_iocn);
                showGetSDcardPermissDialog(downLoadInfo, hoder, position, true);
            } catch (Exception e) {
                e.getStackTrace();
            }

        }
    };

    private final int CODE_REQUEST_WRITESD_PERMISSION = 8800;
    private CWDialog getSDcardPermissDialog;

    /**
     * 获取SDcard权限提示框
     */
    private boolean showGetSDcardPermissDialog(final DownLoadInfo downLoadInfo, final Hoder hoder, final int position, final boolean isHandClick) {
        boolean isHavePermiss = XXPermissionTool.isHasPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
        if (isHavePermiss) {
            checkSDcardpermiss(downLoadInfo, hoder, position, true);
        } else {
            if (getSDcardPermissDialog == null) {
                getSDcardPermissDialog = new CWDialog(this);
                getSDcardPermissDialog.setTitle(R.string.get_permiss_title);
                getSDcardPermissDialog.setTitleTextColor(Color.BLACK);
                getSDcardPermissDialog.setMessage(getString(R.string.get_sdcard_permiss_content), 16, Color.BLACK, Gravity.LEFT);
                getSDcardPermissDialog.setPositiveButton(R.string.get_permiss_ok, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        getSDcardPermissDialog.dismiss();
                        checkSDcardpermiss(downLoadInfo, hoder, position, true);
                    }
                });
                getSDcardPermissDialog.setNegativeButton(R.string.get_permiss_no, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        getSDcardPermissDialog.dismiss();
                    }
                });
            }
            getSDcardPermissDialog.show();
        }
        return true;
    }

    /**
     * 使用sd卡，判断权限
     */
    private boolean checkSDcardpermiss(final DownLoadInfo downLoadInfo, final Hoder hoder, final int position, final boolean isHandClick) {
        if (Build.VERSION.SDK_INT >= 23
                && getApplicationInfo().targetSdkVersion >= 23) {
            List<String> permissionList = new ArrayList<String>();
            Map<String, String> noteMap = new HashMap<>();
            permissionList.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
            noteMap.put(Manifest.permission.WRITE_EXTERNAL_STORAGE, "读写本地存储权限");
            XXPermissionTool.checkPermissions(this, //
                    permissionList, //
                    noteMap, //
                    CODE_REQUEST_WRITESD_PERMISSION, //
                    new XXPermissionTool.OnCheckPermissionsFinishedListener() {
                        @Override
                        public void onCheckPermissionsFinished(int flag) {
                            if (0 == flag) {
                                doClickListener(downLoadInfo, hoder, position, true);
                            }
                        }
                    });
        } else {
            doClickListener(downLoadInfo, hoder, position, true);
        }
        return true;
    }

    /**
     * item监听事件
     *
     * @param downLoadInfo
     */
    public void doClickListener(final DownLoadInfo downLoadInfo, Hoder hoder, int position, boolean isHandClick) {
        try {
            if (ModuleInfo.ModuleInfoId.MODULE_ID_ESSAY == Integer.valueOf(downLoadInfo.getModuleId())) {
                //新闻不用下载资源
                downloadComplete(downLoadInfo, isPreview, isHandClick);
                return;
            }
            if (TextUtils.isEmpty(downLoadInfo.getUrl())) {
                showToastError(R.string.package_no_publish);
                return;
            }
            downLoadInfoMap.put(downLoadInfo, hoder);
            switch (downLoadInfo.getStatus()) {
                case DownloadStatus.STATUS_NORMAL:
                case DownloadStatus.STATUS_FAILED:
                case DownloadStatus.STATUS_FAILED_SDISFULL:
                case DownloadStatus.STATUS_FAILED_UNZIP:
                    if (DialogUtil
                            .sdIsFullForDownload(NewTypeQrDetailActivity.this, downLoadInfo)) {
                        DialogUtil.showSdFullDialog(
                                NewTypeQrDetailActivity.this,
                                downLoadInfo.getSize());
                        return;
                    }
                    if (!NetworkUtils.isOnline()) {
                        ToastUtil.INSTANCE.toastCenterNoNetError();
                        return;
                    }
//                    downLoadInfo.setHash(catalogueInfo.getHash());//只有下载的时候更新HASH值
                    DownLoad.getInstance().pauseTask(downLoadInfo);
                    DownLoad.getInstance().resumeTask(downLoadInfo);
                    judgeDownloadMethod(downLoadInfo, hoder, position);
                    break;
                case DownloadStatus.STATUS_LOADING:
                    DownLoad.getInstance().pauseTask(downLoadInfo);
                    break;
                case DownloadStatus.STATUS_DOWNLOADING:
                    DownLoad.getInstance()
                            .pauseTask(downLoadInfo);
                    break;
                case DownloadStatus.STATUS_PAUSE:
                    if (!NetworkUtils.isOnline()) {
                        ToastUtil.INSTANCE.toastCenterNoNetError();
                        return;
                    }
                    if (NetworkUtils.isWifiOnline()) {
                        showDownloadDialog(downLoadInfo, hoder, position);
                        DownLoad.getInstance()
                                .resumeTask(downLoadInfo);
                    } else {
                        DialogUtil.showWIFIDialogOfNewTypeQrDetail(
                                NewTypeQrDetailActivity.this,
                                downLoadInfo, hoder, position);
                    }
                    break;
                case DownloadStatus.STATUS_UPZIPING:
                    // DownLoad.getInstance().addTask(info);
                    break;
                case DownloadStatus.STATUS_COMPLETED:
                    //新包拆分逻辑增加 资源 versionId,
//                        String catalogueJsonPath = ESystem.getPackagesCatalogueJsonPath(downLoadInfo.getBookId(), downLoadInfo.getChapterId());
                    String resourcePath = ESystem.getPackagesJsonPathNew(downLoadInfo.getBookId(), downLoadInfo.getChapterId(), downLoadInfo.getModuleId(), downLoadInfo.getVersionId());
                    //服务权限判断，跳转资源详情页
                    if (new File(resourcePath).exists()) {
                        downloadComplete(downLoadInfo, isPreview, isHandClick);
                    } else {
                        downLoadInfo.setStatus(DownloadStatus.STATUS_NORMAL);
                        downLoadInfo.setProgress(0);
                        judgeDownloadMethod(downLoadInfo, hoder, position);
                    }

                    break;
            }
        } catch (Exception e) {
            e.getStackTrace();
        }
    }

    private void judgeDownloadMethod(DownLoadInfo downLoadInfo, Hoder hoder, int position) {
        if (NetworkUtils.isOnline()) {
            if (NetworkUtils.isWifiOnline()) {
                showDownloadDialog(downLoadInfo, hoder, position);
                DownLoad.getInstance()
                        .addTask(downLoadInfo);
            } else {
                DialogUtil.showWIFIDialogOfNewTypeQrDetail(
                        NewTypeQrDetailActivity.this,
                        downLoadInfo, hoder, position);
            }
        } else {
            ToastUtil.INSTANCE.toastCenterNoNetError();

        }

    }

    private void downloadComplete(final DownLoadInfo downLoadInfo, boolean isPreview, boolean isHandClick) {
        try {

            if (!isHandClick) {
                boolean downloadInfoTheSame = HomeWorkUtil.isDownloadInfoTheSameToClickDownLoadInfo(downLoadInfo, mCurrentClickDownloadInfo);
                //解决打开两个不同类型作业问题
                if (!downloadInfoTheSame) {
                    return;
                }

                //下载完成自动打开判断是否下载框还存在，如果不存在，不往下走
                if (!isDownloadProessBarShowing()) {
                    return;
                }
            }

            if (isHandClick) {
                showDownloadProgress();
            }
            if (isPreview) {
                jumpSuss(downLoadInfo);
            } else {
                //扫一扫章节详情权限判断
                ServicePermissionJudgeUtil.servicePermissionFilter2(NewTypeQrDetailActivity.this, downLoadInfo, null, null, null, -1, null, -1, isPreview, false, new BaseCallBack() {
                    @Override
                    public void failed(int errorCode, Object data) {
                        hideDownloadProgress();
                        // mHandler.sendEmptyMessageDelayed(0, 2000);
                    }

                    @Override
                    public void failed(Object data) {
                        hideDownloadProgress();
                        // mHandler.sendEmptyMessageDelayed(0, 2000);
                    }

                    @Override
                    public void success(Object data) {
                        final CheckValidBean checkValidBean = (CheckValidBean) data;
                        //  mHandler.sendEmptyMessageDelayed(0, 2000);
                        //没有权限
                        //   int moduleId = mModule.getModuleInfo().getModuleId();
                        if (checkValidBean != null && checkValidBean.isValid == 1 ||
                                downLoadInfo.getModuleId().equals(ModuleInfo.ModuleInfoId.MODULE_ID_VIDEO_EXPLAIN) ||
                                downLoadInfo.getModuleId().equals(ModuleInfo.ModuleInfoId.MODULE_ID_VIDEO_EXPLAIN_NEW)) {
                            hideDownloadProgress();
                        } else {
                            //扫描特有 逻辑
                            MultipleServicesDialog.OnServicesItemClick onServicesItemClick = new MultipleServicesDialog.OnServicesItemClick() {
                                @Override
                                public void onServicesItemClick(int position) {
                                    MeJumpManager.jumpBuyService(NewTypeQrDetailActivity.this, R.string.go_back, checkValidBean.services.get(position).id, -1, RequestCode.MainActivityResquestCode.REQUEST_CODE_TO_PAY, checkValidBean.msg);
                                }
                            };

                            MultipleServicesDialog multipleServicesDialog = new MultipleServicesDialog(NewTypeQrDetailActivity.this, checkValidBean.services, onServicesItemClick);
                            try {//有可能已经退出扫码界面，才请求到权限。防止崩溃。
                                if (checkValidBean.services.size() == 1) {
                                    MeJumpManager.jumpBuyService(NewTypeQrDetailActivity.this, R.string.go_back, checkValidBean.services.get(0).id, -1, RequestCode.MainActivityResquestCode.REQUEST_CODE_TO_PAY, checkValidBean.msg);
                                } else {
                                    multipleServicesDialog.show();
                                    multipleServicesDialog.setTitle(checkValidBean.msg);
                                }
                                //弹框消失后取消下载框
                                multipleServicesDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                                    @Override
                                    public void onDismiss(DialogInterface dialog) {
                                        hideDownloadProgress();
                                    }
                                });
                            } catch (Exception e) {
                                e.getStackTrace();

                            } finally {

                            }
                        }
                    }


                });
            }


        } catch (Exception e) {
            e.getStackTrace();
        }


    }

    //隐藏加载框
    public void onEventMainThread(HideDownloadDialogBean hideDownloadDialogBean) {
        hideDownloadProgress();
    }

    public void onEventMainThread(EventBusFactory.DownloadEvent item) {
        DownLoadInfo downLoadInfo = item.getInfo();
        try {
            mCurrentDownloadInfo = downLoadInfo;
            Hoder hoder = findHoder(downLoadInfo);
            dealCircleProgress(downLoadInfo, hoder);
        } catch (Exception e) {
            e.getStackTrace();
        }
    }

    private Hoder findHoder(DownLoadInfo info) {
        try {
            for (DownLoadInfo key : downLoadInfoMap.keySet()) {
                if (key.getModuleId().equals(info.getModuleId()) && key.getVersionId().equals(info.getVersionId())) {
//                debug("----------keykey-------------" + key.getChapterId() + "-----固定的info------" + info.getChapterId() + "---------name--" + key.getChapterName() + "----" + info.getChapterName());
                    return downLoadInfoMap.get(key);
                }
            }
        } catch (Exception e) {
            e.getStackTrace();
        }

        return null;
    }

    private void dealCircleProgress(final DownLoadInfo info, Hoder hoder) {
        try {
            if (Integer.parseInt(info.getModuleId()) == ModuleInfo.ModuleInfoId.MODULE_ID_ESSAY) {
//                progressCircle.initToCompleted();
            } else {
                switch (info.getStatus()) {
                    case DownloadStatus.STATUS_FILE_DOWNLOAD:
                        hideDownloadHorizontalProgressBar();
                        hideCancelButtonOfDownloadProgress();
                        break;
                    case DownloadStatus.STATUS_COMPLETED:
                        String resourcePath = ESystem.getPackagesJsonPathNew(info.getBookId(), info.getChapterId(), info.getModuleId(), info.getVersionId());
                        if (new File(resourcePath).exists()) {
                            downloadComplete(info, isPreview, false);
                        } else {
                            //这个状态表示没有下载成功
                            hideDownloadProgress();
                            info.setStatus(DownloadStatus.STATUS_NORMAL);
                            info.setProgress(0);
                            ThreadTask.getInstance().executorDBThread(new Runnable() {
                                public void run() {
                                    DownLoadDB.insertDetail(info);
                                }
                            }, ThreadTask.ThreadPeriod.PERIOD_HIGHT);
                            ToastUtil.INSTANCE.toastCenterError(R.string.load_failed_and_retry);
                        }

                        break;
                    case DownloadStatus.STATUS_FAILED:
                        hideDownloadProgress();
                        ToastUtil.INSTANCE.toastCenterError(R.string.load_failed_and_retry);
                        break;
                    case DownloadStatus.STATUS_FAILED_SDISFULL:
                        hideDownloadProgress();
                        ToastUtil.INSTANCE.toastCenterError(R.string.load_failed_sdfull_and_retry);
                        break;
                    case DownloadStatus.STATUS_FAILED_UNZIP:
                        hideDownloadProgress();
                        ToastUtil.INSTANCE.toastCenterError(R.string.load_failed_unzip_and_retry);
                        break;
                    case DownloadStatus.STATUS_DOWNLOADING:
                        if (HomeWorkUtil.isDownloadInfoTheSameToClickDownLoadInfo(info, mCurrentClickDownloadInfo)) {
                            updateDownloadProgress(info.getProgress());
                        }
                        break;
                }
            }

        } catch (Exception e) {
            e.getStackTrace();
        }

    }

    //不需要判断权限
    public void jumpSuss(DownLoadInfo downLoadInfo) {
        try {

            int moduleId = Integer.parseInt(downLoadInfo.getModuleId());
            if (moduleId != ModuleInfo.ModuleInfoId.MODULE_ID_ONLINE_ANSWER) {
                hideDownloadProgress();
            }
            switch (moduleId) {
                case ModuleInfo.ModuleInfoId.MODULE_ID_VIDEO_EXPLAIN_NEW:
                case ModuleInfo.ModuleInfoId.MODULE_ID_VIDEO_EXPLAIN:

                    ViedoJumpManager.jumpToNewVideoExplationActivityPreView(R.string.go_back, NewTypeQrDetailActivity.this, downLoadInfo, null, 0, null, null, 0, isPreview, null);
                    break;
                // 同步测试
                case ModuleInfo.ModuleInfoId.MODULE_ID_TEST:
                    String packagesJsonPath;
                    packagesJsonPath = ESystem.getPackagesJsonPathNew(downLoadInfo.getBookId(), downLoadInfo.getChapterId(), downLoadInfo.getModuleId(), downLoadInfo.getVersionId());


                    if (new File(packagesJsonPath).exists()) {
                        EpaperJumpManager.jumpToDictaion(
                                R.string.go_back, NewTypeQrDetailActivity.this, downLoadInfo,
                                null, -1);
                    } else {
                        CWToast.makeText(NewTypeQrDetailActivity.this, R.string.offline_answer,
                                Toast.LENGTH_LONG, true)
                                .setToastType(CWToast.TOAST_TYPE_SUC)
                                .show();
                    }
                    break;

                // 听说模考
                case ModuleInfo.ModuleInfoId.MODULE_ID_LISTEN_SPEAK_EXAM:
                    if (DialogUtil.sdIsFull(downLoadInfo)) {
                        DialogUtil.showSdFullDialog(NewTypeQrDetailActivity.this);
                        return;
                    }
                    int lsMode = ListenSpeakUtil.LsMode.OWN_PRACTISE;

                    if (downLoadInfo.getType() == CatalogueInfo.PackageMode.PACKAGE_MODE_NEW) {

                        EpaperJumpManager.jumpToListenSpeakWorkNew(R.string.go_back,
                                NewTypeQrDetailActivity.this,false, "0", 0, downLoadInfo, null, "", lsMode, -1, null, 0, 0);
                    }

                    break;

                // 同步跟读
                case ModuleInfo.ModuleInfoId.MODULE_ID_REPEAT:
                    if (DialogUtil.sdIsFull(downLoadInfo)) {
                        DialogUtil.showSdFullDialog(NewTypeQrDetailActivity.this);
                        return;
                    }
                    ChooseReadDialog dialog = new ChooseReadDialog(NewTypeQrDetailActivity.this, "0",
                            downLoadInfo, null, -1, downLoadInfo.getResourceType(),
                            -1, -1, effectiveDate);
                    dialog.show();
                    break;
                // 新资源区分
                // 句子跟读
                case ModuleInfo.ModuleInfoId.MODULE_ID_SENTENCE_REPEAT:
                    if (DialogUtil.sdIsFull(downLoadInfo)) {
                        DialogUtil.showSdFullDialog(NewTypeQrDetailActivity.this);
                        return;
                    }
                    ChooseReadDialog dialog2 = new ChooseReadDialog(NewTypeQrDetailActivity.this, "0",
                            downLoadInfo, null, -1, downLoadInfo.getResourceType(),
                            -1, -1, effectiveDate);
                    dialog2.show();
                    break;
                // 报听写
                case ModuleInfo.ModuleInfoId.MODULE_ID_DICTATION:
                    String classId = "";
                    if (EApplication.getInstance().getClazz() != null) {
                        classId = String.valueOf(EApplication.getInstance().getClazz().getClassId());
                    }
                    EpaperJumpManager.jumpToDictaionNew(R.string.go_back, NewTypeQrDetailActivity.this, "0", downLoadInfo, null, -1, -1, classId, null, -1, false, null, effectiveDate);
                    break;

                // 时文
                case ModuleInfo.ModuleInfoId.MODULE_ID_ESSAY:

                    MeJumpManager.jumpToTimeNewsH5Activity(R.string.go_back, NewTypeQrDetailActivity.this, downLoadInfo, null, -1);
                    break;

                // 在线作答
                case ModuleInfo.ModuleInfoId.MODULE_ID_ONLINE_ANSWER:

                    MeJumpManager.jumpToOnlineAnswerCordovaActivity2(NewTypeQrDetailActivity.this, null, null, downLoadInfo, -1, -1, OnlineAnswerCordovaActivity.FROM_DESK, "", 0, RequestCode.MainActivityResquestCode.REQUEST_CODE_TO_DO_WORK);

                    break;
                //互动教程
                case ModuleInfo.ModuleInfoId.MODULE_ID_INTERACTIVE_TUTORIAL:

                    MeJumpManager.jumpToInteractiveTutorialCordovaActivity(NewTypeQrDetailActivity.this, null, null, downLoadInfo, -1, -1, InteractiveTutorialCordovaActivity.FROM_DESK, "", 0, RequestCode.MainActivityResquestCode.REQUEST_CODE_TO_DO_WORK);

                    break;
                default:
                    CWToast.makeText(NewTypeQrDetailActivity.this, R.string.unknown_type,
                            Toast.LENGTH_LONG, true)
                            .setToastType(CWToast.TOAST_TYPE_SUC).show();
                    break;
            }
        } catch (Exception e) {
            e.getStackTrace();
        }

    }


    public static class Hoder {
        public ImageView imageView_download;
    }


    private DownLoadInfo mCurrentDownloadInfo;
    private DownLoadInfo mCurrentClickDownloadInfo;
    private Hoder mCurrentHolder;
    private int mCurrentPosition;

    public void showDownloadDialog(DownLoadInfo downLoadInfo, Hoder hoder, int position) {
        mCurrentHolder = hoder;
        mCurrentPosition = position;
        showDownloadProgress();
        showCancelButtonOfDownloadProgress();
    }

}
